package ControlLayer;

import ModelLayer.PartialAssignment;
import DBLayer.DBPartialAssignment;
import java.util.ArrayList;

public class CtrPartialAssignment 
{
	
	public int insertPartialAssignment(String nameAssignment, double area, double hourExpected) throws Exception 
	{
	  PartialAssignment part = new PartialAssignment();
	
	  part.setIdPartialAssignment("nextIdPartialAssignment");
	  //part.setMaterialList().get(1).setIdMaterial();
	  //part.setEmployee().setIdEmployee();
	  part.setNameAssignment("Something something darkside");
	  part.setArea(10);
	  part.setHourExpected(5);
	  part.setHourSpent(2);
	  part.setNote("Blablahblah something darkside");
	  part.setPriceAssignment(22);
	
	  DBPartialAssignment dbPart = new DBPartialAssignment();
	  int i = dbPart.insertPartialAssignment(part);
	
	  if(i == 1){
	      System.out.println("Added");
	  }
	  return i;
	}
	
	public ArrayList<PartialAssignment> getAllPartialAssignments() throws Exception 
	{
		ArrayList<PartialAssignment> parList = new ArrayList<PartialAssignment>();
	    DBPartialAssignment dbPar = new DBPartialAssignment();
	    parList = dbPar.getAllPartialAssignments();
	
	    return parList;
	}
	
	public PartialAssignment findPartialAssignmentId(String idPartialAssignment) throws Exception 
	{
		PartialAssignment parAss = new PartialAssignment();
		DBPartialAssignment dbPart = new DBPartialAssignment();
		parAss = dbPart.findPartialAssignmentId(idPartialAssignment);
		
		return parAss;
	}
	
	public PartialAssignment findPartialAssignmentName(String namePartialAssignment) throws Exception 
	{
		PartialAssignment parAss = new PartialAssignment();
		DBPartialAssignment dbPart = new DBPartialAssignment();
		parAss = dbPart.findPartialAssignmentName(namePartialAssignment);
		
		return parAss;
	}

}
